//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.ec.controller;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.PageInfo;
import com.hustcad.plm.basic.log.LogEventEnum;
import com.hustcad.plm.basic.util.TySecurityLabelsUtil;
import com.hustcad.plm.pdm.audit.util.TyplmAuditLogUtil;
import com.hustcad.plm.pdm.ec.module.dto.*;
import com.hustcad.plm.pdm.ec.module.vo.ChgFormVO;
import com.hustcad.plm.pdm.ec.module.vo.ECObjDataVO;
import com.hustcad.plm.pdm.ec.module.vo.EngineeringChangeVo;
import com.hustcad.plm.pdm.ec.module.vo.PreviewEcFromVo;
import com.hustcad.plm.pdm.ec.service.TyChangeExtService;
import com.hustcad.plm.pdm.ec.service.TyplmChangeObjectLinkService;
import com.hustcad.plm.pdm.ec.service.TyplmEngineeringChangeService;
import com.hustcad.plm.pdm.type.model.vo.TypeTree;
import com.jsyxdl.utils.FormTemplateAndDataUtils;
import com.ty.basic.entity.IdentifierEntity;
import com.ty.basic.entity.audit.AuditLogDO;
import com.ty.basic.handler.exceptionhandler.exception.ResponseCodeEnum;
import com.ty.basic.handler.exceptionhandler.exception.TyException;
import com.ty.basic.handler.exceptionhandler.response.ResponseResult;
import com.ty.basic.utils.ArgumentUtils;
import com.ty.basic.utils.PageSizeUtil;
import com.ty.security.util.TyCommonUtils;
import com.ty.security.util.TyJsonDataUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

@Api(
        tags = {"变更管理"}
)
@RestController
@RequestMapping({"/rest/v1/engineeringChange"})
public class TyplmEngineeringChangeController {
    private static final Logger log = LoggerFactory.getLogger(TyplmEngineeringChangeController.class);
    @Autowired
    private TyplmEngineeringChangeService typlmEngineeringChangeService;
    @Autowired
    private TyChangeExtService tyChangeExtService;
    @Resource
    private TyplmChangeObjectLinkService typlmChangeObjectLinkService;
    private static final String CTY_CHANGE_NOTICE_OTYPE = "ty.inteplm.change.CTyChangeNotice";
    private static final String KEY_ENTITY = "entity";
    private static final String KEY_RELENTITY = "relentity";
    private static final String KEY_BEFORE = "before";

    public TyplmEngineeringChangeController() {
    }

    /** @deprecated */
    @Deprecated
    @ApiOperation(
            value = "新建变更单/发布单",
            notes = "新建变更单/发布单",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/createChgForm"})
    public ResponseResult<ChgFormVO> createChgForm(List<MultipartFile> fileList, HttpServletRequest request) {
        String params = (String)TyCommonUtils.requireNonNull(request.getParameter("params"), "params");
        LinkedHashMap<String, String> descriptionMap = (LinkedHashMap)JSON.parseObject(request.getParameter("descriptionMap"), LinkedHashMap.class);
        ChgFormVO formVO = (ChgFormVO)JSON.parseObject(params, ChgFormVO.class);

        try {
            ChgFormVO chgForm = this.typlmEngineeringChangeService.createChgForm(formVO, fileList, descriptionMap);
            TyplmAuditLogUtil.info(chgForm.getOid(), chgForm.getOtype(), LogEventEnum.CRATE_OBJECT);
            TyplmAuditLogUtil.sendCollectInfo();
            return TyCommonUtils.getSuccess(chgForm);
        } catch (Exception var8) {
            AuditLogDO auditLogDO = new AuditLogDO();
            auditLogDO.setObjoid(BigInteger.ZERO);
            auditLogDO.setObjotype(formVO.getEcnOtype());
            auditLogDO.setContaineroid(formVO.getContainerOid());
            auditLogDO.setContainerotype(formVO.getContainerOtype());
            auditLogDO.setTargettype(formVO.getType());
            auditLogDO.setTargetnumber(formVO.getName());
            auditLogDO.setTargetsecuritylabels(formVO.getSecuritylabels());
            auditLogDO.setLifecyclestageoid(formVO.getLifecycleTemplateOid());
            auditLogDO.setLifecyclestageotype(formVO.getLifecycleTemplateOtype());
            auditLogDO.setLifecyclestatekey(formVO.getLifecycleStageKey());
            TyplmAuditLogUtil.errorInfo(LogEventEnum.CRATE_OBJECT, auditLogDO, var8);
            throw var8;
        }
    }

    @ApiOperation(
            value = "编辑变更单/发布单",
            notes = "编辑变更单/发布单",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/updateChgForm"})
    public ResponseResult<ChgFormVO> updateChgForm(@RequestBody ChgFormVO formVO) {
        ArgumentUtils.checkArgumentNull(formVO.getEcnOid(), "ecnOid");
        ArgumentUtils.checkArgumentNull(formVO.getEcnOtype(), "ecnOtype");

        try {
            String oldSecurityLabels = TySecurityLabelsUtil.getSecurityLabels(formVO.getEcnOid(), formVO.getEcnOtype());
            //FormTemplateAndDataUtils.updateChgFormByFormData(formVO);

            ChgFormVO chgForm = this.typlmEngineeringChangeService.updateChgForm(formVO);

            if (!StringUtils.equals(oldSecurityLabels, chgForm.getSecuritylabels())) {
                TyplmAuditLogUtil.info(formVO.getEcnOid(), formVO.getEcnOtype(), LogEventEnum.UPDATE_OBJECT, String.format("密级[%s -> %s]", oldSecurityLabels, chgForm.getSecuritylabels()));
            } else {
                TyplmAuditLogUtil.info(formVO.getEcnOid(), formVO.getEcnOtype(), LogEventEnum.UPDATE_OBJECT);
            }

            TyplmAuditLogUtil.sendCollectInfo();
            return TyCommonUtils.getSuccess(chgForm);
        } catch (Exception var4) {
            TyplmAuditLogUtil.errorInfo(formVO.getEcnOid(), formVO.getEcnOtype(), LogEventEnum.UPDATE_OBJECT, var4);
            throw var4;
        }
    }

    @ApiOperation(
            value = "删除变更单/发布单",
            notes = "删除变更单/发布单",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/deleteChgForm"})
    public ResponseResult<Boolean> deleteChgForm(@RequestBody ChgFormVO formVO) {
        ArgumentUtils.checkArgumentNull(formVO.getEcnOid(), "ecnOid");
        ArgumentUtils.checkArgumentNull(formVO.getEcnOtype(), "ecnOtype");

        try {
            TyplmAuditLogUtil.info(formVO.getEcnOid(), formVO.getEcnOtype(), LogEventEnum.DELETE_OBJECT);
            this.typlmEngineeringChangeService.deleteChgForm(formVO);
            TyplmAuditLogUtil.sendCollectInfo();
            return TyCommonUtils.getSuccess(true);
        } catch (Exception var3) {
            TyplmAuditLogUtil.errorInfo(formVO.getEcnOid(), formVO.getEcnOtype(), LogEventEnum.DELETE_OBJECT, var3);
            throw var3;
        }
    }

    @PostMapping({"/getChgFormByEcIdentifierEntity"})
    @ApiOperation(
            value = "根据变更单id查询变更单详情",
            notes = "根据变更单id查询变更单详情，传入ecn或者eca的IdentifierEntity，后台切换，前端只接收数据",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<ChgFormVO> getChgFormByEcIdentifierEntity(@RequestBody ChgFormByEcIdentifierDto dto) {
        ArgumentUtils.checkArgumentNull(dto.getOid(), "oid");
        ArgumentUtils.checkArgumentNull(dto.getOtype(), "otype");

        try {
            TyplmFlowTaskInfoDTO taskInfoDTO = (new TyplmFlowTaskInfoDTO()).setTaskId(dto.getTaskId()).setTaskDefKey(dto.getTaskDefKey()).setEditable(dto.getEditable());
            ChgFormVO form = this.typlmEngineeringChangeService.getChgFormByEcIdentifierEntity(new IdentifierEntity(dto.getOid(), dto.getOtype()), taskInfoDTO);
            if (form != null) {
//                if(FormTemplateAndDataUtils.updateChgFormByFormData(form)){
//                    //form = this.typlmEngineeringChangeService.updateChgForm(form);
//                }

                TyplmAuditLogUtil.info(form.getOid(), form.getOtype(), LogEventEnum.VIEW_OBJECT);
                TyplmAuditLogUtil.sendCollectInfo();
            }

            return TyCommonUtils.getSuccess(form, SerializerFeature.WriteDateUseDateFormat);
        } catch (Exception var4) {
            TyplmAuditLogUtil.errorInfo(dto.getOid(), dto.getOtype(), LogEventEnum.VIEW_OBJECT, var4);
            throw var4;
        }
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/getEngineeringPublishType"})
    @ApiOperation(
            value = "获取发布单的子类型树",
            notes = "获取发布单的子类型树",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<TypeTree>> getEngineeringPublishType() {
        EngineeringChangeVo engineeringChangeVo = new EngineeringChangeVo();
        engineeringChangeVo.setParam("PublishNotice");
        engineeringChangeVo.setOtype("ty.inteplm.change.CTyChangeNotice");
        return ResponseResult.success(this.typlmEngineeringChangeService.getTypeListByEngineeringChangeVo(engineeringChangeVo));
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/getEngineeringChangeType"})
    @ApiOperation(
            value = "获取变更单的子类型树",
            notes = "获取变更单的子类型树",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<TypeTree>> getEngineeringChangeType() {
        EngineeringChangeVo engineeringChangeVo = new EngineeringChangeVo();
        engineeringChangeVo.setParam("ChangeNotice");
        engineeringChangeVo.setOtype("ty.inteplm.change.CTyChangeNotice");
        return ResponseResult.success(this.typlmEngineeringChangeService.getTypeListByEngineeringChangeVo(engineeringChangeVo));
    }

    /** @deprecated */
    @Deprecated
    @ApiOperation(
            value = "变更单添加变更前对象",
            notes = "变更单添加变更前对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/addObjectBeforeChange"})
    public ResponseResult<List<ECObjDataVO>> addObjectBeforeChange(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        IdentifierEntity entity = (IdentifierEntity)((JSONObject)TyCommonUtils.requireNonNull(jsonObject.getJSONObject("entity"), "entity")).toJavaObject(IdentifierEntity.class);
        List<ECObjDTO> ecObjDTOS = ((JSONArray)TyCommonUtils.requireNonNull(jsonObject.getJSONArray("relentity"), "relentity")).toJavaList(ECObjDTO.class);
        Boolean before = (Boolean)TyCommonUtils.requireNonNull(jsonObject.getBoolean("before"), "before");
        return ResponseResult.success(this.typlmEngineeringChangeService.addObjectBeforeOrAfterChange(entity, ecObjDTOS, before));
    }

    @ApiOperation(
            value = "变更单移除变更前对象",
            notes = "变更单移除变更前对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/removeObjectBeforeChange"})
    public ResponseResult<Boolean> removeObjectBeforeChange(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        IdentifierEntity entity = null;
        JSONObject entityJson = jsonObject.getJSONObject("entity");
        if (entityJson != null) {
            entity = (IdentifierEntity)entityJson.toJavaObject(IdentifierEntity.class);
        }

        List<IdentifierEntity> ecObjDTOS = ((JSONArray)TyCommonUtils.requireNonNull(jsonObject.getJSONArray("relentity"), "relentity")).toJavaList(IdentifierEntity.class);
        this.typlmEngineeringChangeService.removeObjectBeforeChange(entity, ecObjDTOS);
        return ResponseResult.success(true);
    }

    @ApiOperation(
            value = "移除变更后对象",
            notes = "移除变更后对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/removeObjectAfterChange"})
    public ResponseResult<ECObjReturnDTO> removeObjectAfterChange(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        IdentifierEntity entity = null;
        JSONObject entityJson = jsonObject.getJSONObject("entity");
        if (entityJson != null) {
            entity = (IdentifierEntity)entityJson.toJavaObject(IdentifierEntity.class);
        }

        List<ECObjDataVO> allRelentity = null;
        JSONArray allRelentityJson = jsonObject.getJSONArray("allRelentity");
        if (allRelentityJson != null) {
            allRelentity = allRelentityJson.toJavaList(ECObjDataVO.class);
        }

        List<ECObjDataVO> ecObjDTOS = ((JSONArray)TyCommonUtils.requireNonNull(jsonObject.getJSONArray("relentity"), "relentity")).toJavaList(ECObjDataVO.class);
        ECObjReturnDTO ecObjReturnDTO = this.typlmEngineeringChangeService.removeObjectAfterChange(entity, allRelentity, ecObjDTOS);
        return ResponseResult.success(ecObjReturnDTO);
    }

    @ApiOperation(
            value = "预览问题单，请求单，变更发布单",
            notes = "预览问题单，请求单，变更发布单",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/previewChgForm"})
    public ResponseResult<PreviewEcFromVo> previewChgForm(@RequestBody IdentifierEntity mainEntity) {
        ArgumentUtils.checkArgumentNull(mainEntity.getOid(), "oid");
        ArgumentUtils.checkArgumentNull(mainEntity.getOtype(), "otype");
        return ResponseResult.success(this.typlmEngineeringChangeService.previewChgForm(mainEntity));
    }

    @ApiOperation(
            value = "我的EC列表",
            notes = "我的EC列表",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/queryMyChgForm"})
    public ResponseResult<PageInfo<ChgFormVO>> queryMyChgForm(@RequestBody ChgFormQueryDTO ecQueryDTO) {
        if (ObjectUtils.isEmpty(ecQueryDTO.getCurPage()) || ecQueryDTO.getCurPage() <= 0) {
            ecQueryDTO.setCurPage(1);
        }

        ecQueryDTO.setPageSize(PageSizeUtil.getNormalSize(ecQueryDTO.getPageSize()));
        ecQueryDTO.setUserIsParam(true);
        return ResponseResult.success(this.typlmEngineeringChangeService.queryMyChgForm(ecQueryDTO));
    }

    @ApiOperation(
            value = "容器EC管理列表",
            notes = "容器EC管理列表",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/queryChgFormByContainer"})
    public ResponseResult<PageInfo<ChgFormVO>> queryChgFormByContainer(@RequestBody ChgFormQueryDTO ecQueryDTO) {
        ArgumentUtils.checkArgumentNull(ecQueryDTO.getContainerOid(), "containerOid");
        ArgumentUtils.checkArgumentNull(ecQueryDTO.getContainerOtype(), "containerOtype");
        if (ObjectUtils.isEmpty(ecQueryDTO.getCurPage()) || ecQueryDTO.getCurPage() <= 0) {
            ecQueryDTO.setCurPage(1);
        }

        if (ObjectUtils.isEmpty(ecQueryDTO.getPageSize())) {
            ecQueryDTO.setPageSize(10);
        }

        ecQueryDTO.setPageSize(PageSizeUtil.getNormalSize(ecQueryDTO.getPageSize()));
        ecQueryDTO.setUserIsParam(false);
        return ResponseResult.success(this.typlmEngineeringChangeService.queryMyChgForm(ecQueryDTO));
    }

    /** @deprecated */
    @Deprecated
    @ApiOperation(
            value = "根据对象获取变更单列表",
            notes = "根据对象获取变更单列表",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/queryChgFormByEntity"})
    public ResponseResult<PageInfo<ChgFormVO>> queryChgFormByEntity(@RequestBody ChgFormQueryDTO ecQueryDTO) {
        TyCommonUtils.requireNonNull(ecQueryDTO.getOid(), "oid");
        TyCommonUtils.requireNonNull(ecQueryDTO.getOtype(), "otype");
        if (ObjectUtils.isEmpty(ecQueryDTO.getCurPage()) || ecQueryDTO.getCurPage() <= 0) {
            ecQueryDTO.setCurPage(1);
        }

        ecQueryDTO.setPageSize(PageSizeUtil.getNormalSize(ecQueryDTO.getPageSize()));
        return ResponseResult.success(this.typlmEngineeringChangeService.queryChgFormByEntity(ecQueryDTO));
    }

    @ApiOperation(
            value = "设置变更前对象列表的变更策略",
            notes = "设置变更前对象列表的变更策略",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/setChangeStrategyByChange"})
    public ResponseResult<List<ECObjData>> setChangeStrategyByChange(@RequestBody ChangeStrategySetDTO changeStrategySetDTO) {
        if (ObjectUtils.isEmpty(changeStrategySetDTO)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        return ResponseResult.success(this.typlmEngineeringChangeService.setChangeStrategyByChange(changeStrategySetDTO.getEcnOid(), changeStrategySetDTO.getAllBeforeObjDTOList(), changeStrategySetDTO.getStrategyObjDTOList(), changeStrategySetDTO.getChangeStrategy()));
    }

    @ApiOperation(
            value = "变更单添加变更前对象",
            notes = "变更单添加变更前对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/addBeforeChangeObjectWithStrategy"})
    public ResponseResult<List<ECObjDataVO>> addBeforeChangeObjectWithStrategy(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        if (JSONUtil.isNull(jsonObject) || jsonObject.isEmpty()) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        ECAddChangeObjectDTO addChangeObjectDTO = (ECAddChangeObjectDTO)jsonObject.toJavaObject(ECAddChangeObjectDTO.class);

        try {
            List<ECObjDataVO> ecObjDataVOS = this.typlmEngineeringChangeService.addBeforeChangeObjectWithStrategy(addChangeObjectDTO);
            this.addAuditLog(addChangeObjectDTO, (Exception)null);
            return ResponseResult.success(ecObjDataVOS);
        } catch (Exception var5) {
            this.addAuditLog(addChangeObjectDTO, var5);
            throw var5;
        }
    }

    @ApiOperation(
            value = "变更单添加变更后对象",
            notes = "变更单添加变更后对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/addAfterChangeObject"})
    public ResponseResult<EcAfterAddReturnDTO> addAfterChangeObject(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        if (JSONUtil.isNull(jsonObject) || jsonObject.isEmpty()) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        ECAddChangeObjectDTO addChangeObjectDTO = (ECAddChangeObjectDTO)jsonObject.toJavaObject(ECAddChangeObjectDTO.class);

        try {
            EcAfterAddReturnDTO returnDTO = this.typlmEngineeringChangeService.addAfterChangeObject(addChangeObjectDTO);
            this.addAuditLog(addChangeObjectDTO, (Exception)null);
            return ResponseResult.success(returnDTO);
        } catch (Exception var5) {
            this.addAuditLog(addChangeObjectDTO, var5);
            throw var5;
        }
    }

    private void addAuditLog(ECAddChangeObjectDTO addChangeObjectDTO, Exception exception) {
        List<ECObjData> addObjDTOList = addChangeObjectDTO.getAddObjDTOList();
        if (!CollectionUtils.isEmpty(addObjDTOList)) {
            Iterator var4 = addObjDTOList.iterator();

            while(var4.hasNext()) {
                ECObjData ecObjData = (ECObjData)var4.next();
                if (exception == null) {
                    TyplmAuditLogUtil.info(ecObjData.getOid(), ecObjData.getOtype(), LogEventEnum.ADD_TO_EC);
                } else {
                    TyplmAuditLogUtil.errorInfo(ecObjData.getOid(), ecObjData.getOtype(), LogEventEnum.ADD_TO_EC, exception);
                }
            }

            TyplmAuditLogUtil.sendCollectInfo();
        }

    }

    /** @deprecated */
    @Deprecated
    @ApiOperation(
            value = "迁移数据处理(迁移ecr相关数据,取消ecr对象逻辑)",
            notes = "迁移数据处理(迁移ecr相关数据,取消ecr对象逻辑)",
            produces = "application/json; charset=utf-8"
    )
    @GetMapping({"/transformHistoricalDataToVersionTwo"})
    public ResponseResult<Boolean> transformHistoricalDataToVersionTwo() {
        this.tyChangeExtService.transformHistoricalDataToVersionTwo();
        return ResponseResult.success(Boolean.TRUE);
    }

    @ApiOperation(
            value = "修改变更对象备注",
            notes = "修改变更对象备注",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/updateChangeObjectDescription"})
    public ResponseResult<Boolean> updateChangeObjectDescription(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        if (JSONUtil.isNull(jsonObject) || jsonObject.isEmpty()) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        UpdateDescriptionDTO updateDescriptionDTO = (UpdateDescriptionDTO)jsonObject.toJavaObject(UpdateDescriptionDTO.class);
        this.typlmEngineeringChangeService.batchUpdateChangeObjectDescription(updateDescriptionDTO);
        return ResponseResult.success(true);
    }

    @ApiOperation(
            value = "撤销变更单",
            notes = "前提：变更单所属流程已终止，执行结果：删除新产生的变更后对象",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/checkAndRollbackChangeByEcn"})
    @Transactional(
            rollbackFor = {Exception.class},
            isolation = Isolation.READ_COMMITTED
    )
    public ResponseResult<Boolean> checkAndRollbackChangeByEcn(@RequestBody JSONObject req) {
        TyCommonUtils.requireNonNull(req, "req");
        JSONObject jsonObject = TyJsonDataUtil.toJSON(req);
        if (JSONUtil.isNull(jsonObject) || jsonObject.isEmpty()) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        BigInteger ecnId = jsonObject.getBigInteger("ecnId");
        this.typlmEngineeringChangeService.checkAndRollbackChangeByEcn(ecnId);
        return ResponseResult.success(true);
    }

    @ApiOperation(
            value = "将普通对象转为变更对象数据格式",
            notes = "将普通对象转为变更对象数据格式",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/convertObjToEcInfo"})
    public ResponseResult<List<ECObjDataVO>> convertObjToEcInfo(@RequestBody List<IdentifierEntity> entityList) {
        ArgumentUtils.checkArgumentNull(entityList, "entityList");
        List<ECObjDataVO> ecObjDataList = this.typlmChangeObjectLinkService.convertObjToEcInfo(entityList);
        return ResponseResult.success(ecObjDataList);
    }

    @ApiOperation(
            value = "查询ECN变更前对象列表",
            notes = "查询ECN变更前对象列表",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/listChangeObjBefore"})
    public ResponseResult<List<ECObjData>> listChangeObjBefore(@RequestBody ChangeObjectDTO changeObjectDTO) {
        ArgumentUtils.checkArgumentNull(changeObjectDTO, "changeObjectDTO");
        List<ECObjData> ecObjDataList = this.typlmEngineeringChangeService.listChangeObjBefore(changeObjectDTO);
        return ResponseResult.success(ecObjDataList);
    }

    @ApiOperation(
            value = "获取变更单/发布单变更后对象列表",
            notes = "获取变更单/发布单变更后对象列表",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/listChangeObjAfter"})
    public ResponseResult<List<ECObjData>> listChangeObjAfter(@RequestBody ChangeObjectDTO changeObjectDTO) {
        ArgumentUtils.checkArgumentNull(changeObjectDTO, "changeObjectDTO");
        List<ECObjData> ecObjDataList = this.typlmEngineeringChangeService.listChangeObjAfter(changeObjectDTO);
        return ResponseResult.success(ecObjDataList);
    }

    @ApiOperation(
            value = "根据对象获取变更格式数据",
            notes = "根据对象获取变更格式数据",
            produces = "application/json; charset=utf-8"
    )
    @PostMapping({"/listObjEcInfo"})
    public ResponseResult<List<ECObjData>> listObjEcInfo(@RequestBody List<IdentifierEntity> objList) {
        ArgumentUtils.checkArgumentNull(objList, "objList");
        List<ECObjData> ecObjDataVOList = this.typlmChangeObjectLinkService.listObjEcInfo(objList);
        return ResponseResult.success(ecObjDataVOList);
    }
}
